<?php
 // START GET DATA THEO GET  METHOD-------------
 

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
	require_once 'libraries/function/validateAjax.php';
//End of rating
if($_GET['thanks']==1){
	$id=intval($_POST['truyen_id']);
	$str='manga';

				if(!isset($_COOKIE["thanks".$id.$str])){
				setcookie("thanks".$id.$str, "1", time()+88000,"/");
				$db=new db;
				$db->connect();
				
				$db->query("select * from thanks where  number=$id and url='".$str."'");
				if($db->num_rows()==0){
					$db->query("insert into thanks(number,url) values($id,'".$str."')");
				}else{
					$sql="update thanks set  num=num+1 where number=".$id." and url='".$str."'";
					$sql2="update manga set  thanks=thanks+1 where id=".$id;
					$db->nonquery($sql);
					$db->nonquery($sql2);
				}
					
				echo "Cám ơn bạn đã ủng hộ topic này ^^!";
			}else
			{
				echo " Bạn đã ủng hộ topic  này rồi !!";
			}
			
			$db->close();	
			
			
			exit();

	
	}//End get thanks


	
} //End of request fist line